# https://leetcode.cn/problems/make-three-strings-equal/


class Solution:
    def findMinimumOperations(self, s1: str, s2: str, s3: str) -> int:
        min_len = min((len(s1), len(s2), len(s3)))
        i = 0
        while i < min_len:
            if s1[i] != s2[i] or s1[i] != s3[i] or s2[i] != s3[i]:
                break
            i += 1
        if i == 0:
            return -1
        return len(s1) - i + len(s2) - i + len(s3) - i